define(['template/setting/indexTpl','wx','wx.ajax','wx.upload','wx.cookie','wx.tpl','wx.validator'],function(tpl,wx){
	var userId;
    var setting = {};
    function init(id){
    	userId = wx.cookie('userid');
    	$('<link href="/res/css/setting.css?t='+(new Date()|0)+'" rel="stylesheet" type="text/css" />').appendTo('head').load(function(){
    		$('#window-frame-setting').html(tpl.about);
            action();
    	});
	}

    function action(){
        wx.upload($('input[name="file"]'));
        wx.validator();
        $('form[name="modifypassword"]').on('validator',function(event,data){
            if(data.status)
                $.succ('密码修改成功');
            else
                $.fail('密码修改失败');
        });
        $('input[name="file"]').on('upload',function(event,data){
            $(window).resize();
            wx.sendData('/who/update','id='+userId+'&data={"destop":"'+data.path+'"}');            
        });
    }
    setting.init = init;
    return setting;
});